package exer;

/**
 * @author tongchen
 * @create 2022-10-09 9:30
 */
public class Solution {
    public static ListNode middleNode(ListNode head) {
        //首先进行循环计数
        int count=0;//题目中明确说明head为非空结点
        ListNode temp=head;
        while(temp!=null){
            temp=temp.next;
            count++;
        }
        int num=count/2+1;
        temp=head;
        for(int i=1;i<num;++i){
            temp=temp.next;
        }
        return temp;
    }
}
